package com.golxen.framework.activity;


import com.golxen.framework.activity.dao.CrossActivityProcessBusiness;
import com.golxen.framework.manager.TempMgr;

import java.util.HashMap;
import java.util.Map;

public class CrossActivityProcessMgr extends TempMgr {
    private static Map<Integer, Integer> activityProcessMap = new HashMap<>();

    @Override
    public boolean reloadData() throws Exception {
        activityProcessMap = CrossActivityProcessBusiness.getAllActivityCrossInfo();
        return true;
    }

    public static Integer getActivityCrossId(int activityId) {

        if (!activityProcessMap.containsKey(activityId)) {
            synchronized (activityProcessMap) {
                if (!activityProcessMap.containsKey(activityId)) {
                    Map<Integer, Integer> map = CrossActivityProcessBusiness.getActivityCrossInfo(activityId);
                    activityProcessMap.putAll(map);
                }
            }
        }
        return activityProcessMap.get(activityId);
    }

    @Override
    public boolean stop() {
        return false;
    }
}
